package net.wofly.sale.commission.service;

import java.util.List;

import net.wofly.common.persistence.PageWrapper;
import net.wofly.common.util.ReturnBean;
import net.wofly.sale.commission.domain.CommissionCfg;
import net.wofly.sale.commission.domain.OrderCommission;
import net.wofly.sale.commission.domain.SaleCommissionSum;

/**
 * @author siqingwei
 */
public interface ICommissionCfgService {

	/**
	 * 增加或修改
	 * 
	 * @param entity
	 * @return
	 */
	CommissionCfg save(CommissionCfg entity);

	/**
	 * 删除
	 * 
	 * @param entity
	 * @return
	 */
	void delete(CommissionCfg entity);

	/**
	 * 根据主键ID删除
	 * 
	 * @param key
	 * @return
	 */
	void delete(String key);

	/**
	 * 根据主键查询
	 * 
	 * @param key
	 * @return
	 */
	CommissionCfg findOne(String key);
	
	List<CommissionCfg> save(List<CommissionCfg> entityList) ;

	/**
	 * 添加新的佣金配置
	 *
	 * @param commissionCfg
	 */
	ReturnBean<CommissionCfg> addCommissionCfg(CommissionCfg commissionCfg);

	/**
	 * 删除佣金配置
	 * <ol>
	 * 	<li>将状态改为无效</li>
	 * 	<li></li>
	 * </ol>
	 *
	 * @param commissionCfgID
	 */
	ReturnBean<CommissionCfg> delCommissionCfg(String commissionCfgID);

	/**
	 * 获取销售的佣金比率
	 * <ol>
	 * 	<li></li>
	 * </ol>
	 *
	 * @param userID
	 */
	ReturnBean<CommissionCfg> getCommissionRateByUser(String userID);

	/**
	 * 销售提成流水
	 * <ol>
	 * 	<li>出纳一旦平帐即可计算佣金</li>
	 * 	<li></li>
	 * </ol>
	 *
	 * @param userID
	 * @param startTime
	 * @param endTime
	 * @param pageNum
	 * @param pageSize
	 */
	ReturnBean<PageWrapper<OrderCommission>> getSaleCommissionDetail(String userID, Long startTime, Long endTime, Integer pageNum, Integer pageSize);

	ReturnBean<List<SaleCommissionSum>> getSaleCommissionMonthSum(Integer sumDuration, Long sumTime);

	/**
	 * 修改佣金配置
	 * <ol>
	 * 	<li>修改佣金配置不是直接修改原来记录。而是将原来记录状态改为无效。则新增一条记录</li>
	 * 	<li></li>
	 * </ol>
	 *
	 * @param commissionCfg
	 */
	ReturnBean<CommissionCfg> updateCommissionCfg(CommissionCfg commissionCfg);

}
